<%--
 *  File:    UmCodeEdit.jsp
 *  @Author: Kent Zhong 
 *  Date:    2002/05/08
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
 

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom-tag.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.UmCodeEdit");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "IMG";
  	String strTableName = "ovumcode";
	String privilegeCode = "Z0804";
  	
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	cat.debug("The userinfo is :"+CurUserInfo);
  	cat.info("enter my page");
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>

<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%
    String strIsNew=request.getParameter("isnew");
    if(strIsNew==null)
    {
        strIsNew="";
    }
    String strId=request.getParameter("umid");
    if(strId==null)
    {
        strId="";
    }
%>
<html>
<head>
<title>UmCodeEdit</title>
<%if(!strIsNew.equals("y")){%>
<PageFlow:CheckPageFlow pageName="umcodeedit"/>
<%}%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">

<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript" >

    function page_valuechange(obj,objhidden)
    {
        var valueobj = eval("document.umcodeeditform." + obj);
        var valueobjhidden = eval("document.umcodeeditform." + objhidden);
        valueobjhidden.value=valueobj.value;
    }
    
    function page_valuechange_int(obj,objhidden)
    {
        var valueobj = eval("document.umcodeeditform." + obj);
        var valueobjhidden = eval("document.umcodeeditform." + objhidden);
        valueobjhidden.value=valueobj.value;
        if(isEmpty(valueobj.value))
        {
            valueobj.value=" ";
            valueobjhidden.value=" ";
        }
    }
    
    function page_codechange(obj,objhidden0,objhidden1)
    {
        var checkedobj = eval("document.umcodeeditform." + obj);
        var valueobjhidden0 = eval("document.umcodeeditform." + objhidden0);
        var valueobjhidden1 = eval("document.umcodeeditform." + objhidden1);
        valueobjhidden0.value=checkedobj.value;
        valueobjhidden1.value=checkedobj.value;
    }
    function page_checkedchange(obj,objhidden0,objhidden1)
    {
        var checkedobj = eval("document.umcodeeditform." + obj);
        var valueobjhidden0 = eval("document.umcodeeditform." + objhidden0);
        var valueobjhidden1 = eval("document.umcodeeditform." + objhidden1);
        if(checkedobj.checked)
        {
            valueobjhidden0.value="Y";
            valueobjhidden1.value="Y";
        }
        else
        {
            valueobjhidden0.value=" ";
            valueobjhidden1.value=" ";
        }
    }
    
    function page_done()
    {
        var blSave= true;
        
        <%--[SCRIPT]  if(isEmpty(document.umcodeeditform.umtype0.value))  [SCRIPT]--%>
        <%--[SCRIPT]  {  [SCRIPT]--%>
        <%--[SCRIPT]      alert('<#%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_Type",false)) %#>');  [SCRIPT]--%>
        <%--[SCRIPT]      blSave= false;  [SCRIPT]--%>
        <%--[SCRIPT]      return;  [SCRIPT]--%>
        <%--[SCRIPT]  }  [SCRIPT]--%>
        if(isEmpty(document.umcodeeditform.umcode0.value))
        {
            alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_UOMCode",false)) %>');
            blSave= false;
            return;
        }
        if(isEmpty(document.umcodeeditform.umname0.value))  
        {
            alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_Name(CN)",false)) %>');
            blSave= false;
            return;
        }
        if(isEmpty(document.umcodeeditform.umname1.value))
        {
            alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_Name(EN)",false)) %>');
            blSave= false;
            return;
        }
        if(blSave)
        {
            if(isEmpty(document.umcodeeditform.umdesc0.value) && !isEmpty(document.umcodeeditform.umdesc1.value))
                document.umcodeeditform.umdesc0.value=document.umcodeeditform.umdesc1.value;
            if(!isEmpty(document.umcodeeditform.umdesc0.value) && isEmpty(document.umcodeeditform.umdesc1.value))
                document.umcodeeditform.umdesc1.value=document.umcodeeditform.umdesc0.value;
            
            document.umcodeeditform.actionname.value="done";
            document.umcodeeditform.target="_parent";
            isRunning = true;
            document.umcodeeditform.submit();
        }
        else
            return;
    }

	function page_cancel()
	{ 
	   document.location.href= self.location + "";
	}
	
<%--[SCRIPT]    [SCRIPT]--%>
</script>
</head>
<body>
<form name="umcodeeditform" method="post" action="../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="umcodeedit">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    
    <input type=hidden name=numrows value="2">
<%
    Vector umcodeinfo=(Vector)pageContext.getAttribute("umcodeinfo");
    if(umcodeinfo==null)
    {
        umcodeinfo=new Vector();
    }
    cat.debug("umcodeinfo is :"+umcodeinfo);
    
    HashMap hmCnInfo=new HashMap();
    HashMap hmEnInfo=new HashMap();
    if(umcodeinfo.size()>1)
    {
        if(((String)((HashMap)umcodeinfo.get(0)).get("languagecode")).equalsIgnoreCase("cn"))
        {
            hmCnInfo=(HashMap)umcodeinfo.get(0);
            hmEnInfo=(HashMap)umcodeinfo.get(1);
        }
        else
        {
            hmCnInfo=(HashMap)umcodeinfo.get(1);
            hmEnInfo=(HashMap)umcodeinfo.get(0);
        }
    }
    cat.debug("hmCnInfo is "+hmCnInfo);
    cat.debug("hmEnInfo is "+hmEnInfo);
    
    String strIsBase=(String)hmCnInfo.get("isbase");
    if(strIsBase==null)
    {
        strIsBase="";
    }
    String strIsBaseChecked="";
    if(strIsBase.equalsIgnoreCase("Y"))
    {
        strIsBaseChecked="CHECKED";
    }
    else
    {
         strIsBaseChecked="";
    }
    
    String strType=(String)hmCnInfo.get("umtype");
    if(strType==null)
    {
        strType="";
    }
    
%>   
<%if( !strIsNew.equals("y")){%>
<input type=hidden name="umid2" value='<%=JspHelper.filterNull(hmCnInfo.get("umid"))%>'>
<input type=hidden name="umid3" value='<%=JspHelper.filterNull(hmEnInfo.get("umid"))%>'>
<input type=hidden name="umid0" value='<%=JspHelper.filterNull(hmCnInfo.get("umid"))%>'>
<input type=hidden name="umid1" value='<%=JspHelper.filterNull(hmEnInfo.get("umid"))%>'>
<%}%>
<%if( strIsNew.equals("y")){%>
<input type=hidden name="languagecode0" value='cn'>
<input type=hidden name="languagecode1" value='en'>
<%}else{%>
<input type=hidden name="languagecode0" value='<%=JspHelper.filterNull(hmCnInfo.get("languagecode"))%>'>
<input type=hidden name="languagecode1" value='<%=JspHelper.filterNull(hmEnInfo.get("languagecode"))%>'>
<%}%>
<input type=hidden name="umcode" value='<%=JspHelper.filterNull(hmCnInfo.get("umcode"))%>'>

<input type=hidden name="umcode1" value='<%=JspHelper.filterNull(hmEnInfo.get("umcode"))%>'>
<input type=hidden name="umtype1" value='<%=JspHelper.filterNull(hmEnInfo.get("umtype"))%>'>
<input type=hidden name="isbase1" value='<%=JspHelper.filterNull(hmEnInfo.get("isbase"))%>'>
<input type=hidden name="isbase0" value='<%=JspHelper.filterNull(hmCnInfo.get("isbase"))%>'>
<input type=hidden name="factor1" value='<%=JspHelper.filterNull(hmEnInfo.get("factor"))%>'>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr> 
    <td> 
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td colspan="2" class="summary_top"></td>
        </tr>
        <tr> 
          <td colspan="2"><img src="../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
            <%=label.getLabelName("L_NewEditUOM")+label.getLabelName("L_Colon")%> </td>
        </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr> 
          <td class="need" width="104"><%=label.getLabelName("L_UOMCode")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="umcode0" size="20" value='<%=JspHelper.filterNull(hmCnInfo.get("umcode"))%>'  onchange="javascript:page_codechange('umcode0','umcode1','umcode');">
          </td>
          <td  width="108" class=td-text><%=label.getLabelName("L_Type")+label.getLabelName("L_Colon")%></td>
          <td> 
          <%
            OvalLabel labelEN = new OvalLabel("en",strModuleName); 
            OvalLabel labelCN = new OvalLabel("cn",strModuleName); 
          %>
            <select name="umtype0"  onchange="javascript:page_valuechange('umtype0','umtype1');">
              <option value="">-----</option>
              <option value='<%=JspHelper.filterNull(labelEN.getLabelName("L_Length"))%>' <%if(strType.equalsIgnoreCase(labelCN.getLabelName("L_Length"))||strType.equalsIgnoreCase(labelEN.getLabelName("L_Length")))out.print("Selected");%>><%=label.getLabelName("L_Length")%></option>
              <option value='<%=JspHelper.filterNull(labelEN.getLabelName("L_Weight"))%>' <%if(strType.equalsIgnoreCase(labelCN.getLabelName("L_Weight"))||strType.equalsIgnoreCase(labelEN.getLabelName("L_Weight")))out.print("Selected");%>><%=label.getLabelName("L_Weight")%></option>
              <option value='<%=JspHelper.filterNull(labelEN.getLabelName("L_Volume"))%>' <%if(strType.equalsIgnoreCase(labelCN.getLabelName("L_Volume"))||strType.equalsIgnoreCase(labelEN.getLabelName("L_Volume")))out.print("Selected");%>><%=label.getLabelName("L_Volume")%></option>
              <%--option value='<%=label.getLabelName("L_Other",false)%>' <%if(strType.equalsIgnoreCase(labelCN.getLabelName("L_Other"))||strType.equalsIgnoreCase(labelEN.getLabelName("L_Other")))out.print("Selected");%>><%=label.getLabelName("L_Other")%></option--%>
            
            </select>
          </td>
        </tr>
        <tr> 
          <td class="need"><%=label.getLabelName("L_Name(CN)")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="umname0" size="20"  value='<%=JspHelper.filterNull(hmCnInfo.get("umname"))%>'>
          </td>
          <td class="need"><%=label.getLabelName("L_Name(EN)")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="umname1" value='<%=JspHelper.filterNull(hmEnInfo.get("umname"))%>'  size="20"  >
          </td>
        </tr>
        <tr> 
          <td class="td-text"><%=label.getLabelName("L_Description(CN)")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="umdesc0" size="30"   value='<%=JspHelper.filterNull(hmCnInfo.get("umdesc"))%>' >
          </td>
          <td class="td-text"><%=label.getLabelName("L_Description(EN)")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="umdesc1" size="30"   value='<%=JspHelper.filterNull(hmEnInfo.get("umdesc"))%>' >
          </td>
        </tr>
        <tr> 
          <td class="td-text"><%=label.getLabelName("L_Factor")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="text" name="factor0" size="20"  value='<%=JspHelper.filterNull(hmCnInfo.get("factor"))%>'  onchange="javascript:page_valuechange_int('factor0','factor1');">
          </td>
          <td class="td-text"><%=label.getLabelName("L_IsBasic")+label.getLabelName("L_Colon")%></td>
          <td> 
            <input type="checkbox" name="isbase_show"  class="checkbox" <%=JspHelper.filterNull(strIsBaseChecked)%>  onchange="javascript:page_checkedchange('isbase_show','isbase0','isbase1');">
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td class="summary_top"></td>
  </tr>
  <tr> 
    <td class="td_center">
    <a onclick="page_done();"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
    <a onclick="page_cancel();"><custom:button type="1" label="L_Cancel" imgsrc="cancel.gif" border="0" style="width:60"/></a>
    </td>
  </tr>
</table>
</body>
</html>


